package cn.daichi.redisidempotency.base;

import cn.daichi.redisidempotency.common.HttpStatus;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class Result {

    private Integer code;

    private String msg;

    private Object data;

    public static Result success(Integer code, String msg, Object data) {
        return new Result(code, msg, data);
    }

    public static Result success(String msg, Object data) {
        return success(HttpStatus.SUCCESS.getCode(), msg, data);
    }

    public static Result success(String msg) {
        return success(msg, null);
    }

    public static Result success(Object data) {
        return success(null, data);
    }

    public static Result success() {
        return success(HttpStatus.SUCCESS.getCode(), HttpStatus.SUCCESS.getName(), null);
    }

    public static Result error(Integer code, String msg) {
        return new Result(code, msg, null);
    }

    public static Result error(String msg) {
        return error(HttpStatus.ERROR.getCode(), msg);
    }

    public static Result error() {
        return error(HttpStatus.ERROR.getCode(), HttpStatus.ERROR.getName());
    }

}
